package com.sword.springboot.springboot_thread.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * com.sword.springboot.springboot_thread.service.ThreadService
 * Created by SwordLiu on 2017-11-10.
 */
@Service
public class ThreadService {

    @Async("myExecutor")
    public void threadOne() {
        System.out.println("one:"+Thread.currentThread().getName());
        try {
            Thread.sleep(new Random().nextInt(200));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Async("myExecutor")
    public void threadTow() {
        System.out.println("tow:"+Thread.currentThread().getName());
        try {
            Thread.sleep(new Random().nextInt(200));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
